﻿using Application.AppService.CFSKAppService;
using Application.AppService.CFTKAppService;
using AutoMapper;
using Domain.Entity;
using Microsoft.AspNetCore.Mvc;

namespace UI.Controllers.Customization_Settings_客户化设置_.Human_resource_file_management_人力资源档案管理_
{
	public class CFTKController : Controller
	{
		private readonly ICFTKAppService cFTKAppService;
		private readonly IMapper mapper;

		/// <summary>
		/// Ⅲ级机构设置
		/// </summary>
		/// <returns></returns>
		/// 

		public CFTKController(ICFTKAppService cFTKAppService, IMapper mapper)
		{
			this.cFTKAppService = cFTKAppService;
			this.mapper = mapper;
		}

		public IActionResult Index()
		{
			return View();
		}

		public async Task<IActionResult> AddCFTK(CFTK cFTK)
		{
			bool i = await cFTKAppService.AddCFTKAsync(cFTK);
			return Json(i);
		}

		public async Task<IActionResult> UpdateCFTK(CFTKUpdateDto cFTKUpdateDto)
		{
			CFTK cFTK = mapper.Map<CFTK>(cFTKUpdateDto);
			bool i = await cFTKAppService.UpdateCFTKAsync(cFTK);
			return Json(i);
		}

		public async Task<IActionResult> GetCFTK()
		{
			List<CFTK> cFTKs = await cFTKAppService.GetCFTKAsync();
			return Json(cFTKs);

		}

		public async Task<IActionResult> DeleteCFTK(int id)
		{
			bool i = await cFTKAppService.DeleteCFTKAsync(id);
			return Json(i);
		}
		[HttpGet("GetCFTKById/{id}")]
		public async Task<IActionResult> GetCFTKById(string id)
		{
			List<CFTK> cFTKs = await cFTKAppService.GetCFTKAsyncById(id);
			return Json(cFTKs);
		}
	

	}
}
